#ifndef MONITOR_H
#define MONITOR_H

#include <QMainWindow>
#include <QMouseEvent>
#include "MonitorWork.h"
#include "dialog.h"
#include "navigation.h"
#include "usrlogin.h"
#include "QtMqtt.h"

#include "pages/usrinfo.h"
#include "pages/usrRegister.h"
#include "pages/usrFindpwd.h"
#include "pages/usrBind.h"
#include "pages/usrSettings.h"
#include "pages/DevFaultAlarm.h"
#include "pages/DevFaultList.h"
#include "pages/TianqiYubao.h"
#include "pages/TianqiYubaoSetup.h"
#include "pages/DevicesList.h"
#include "pages/SearchDevice.h"
#include "pages/TopStatistics.h"
#include "pages/FormMap.h"
#include "pages/FDLiangStat.h"
#include "pages/DeviceNews.h"
#include "pages/DeviceStatistics.h"
#include "pages/DeviceStatiSetup.h"
#include "pages/DevCarousel.h"
#include "pages/Blacklist.h"
#include "pages/CameraMonitor.h"

#include "devop/PassWd.h"
#include "devop/V10Main.h"
#include "devop/V15Main.h"
#include "devop/V20Main.h"

QT_BEGIN_NAMESPACE
namespace Ui {
class Monitor;
}
QT_END_NAMESPACE

class Monitor : public QMainWindow
{
    Q_OBJECT

public:
    Monitor(QWidget *parent = nullptr);
    ~Monitor();

protected:
    void mouseMoveEvent(QMouseEvent *e);
    void mousePressEvent(QMouseEvent *e);
    void mouseReleaseEvent(QMouseEvent *);

private:
    Ui::Monitor *ui;
    QThread *threadMonitor;
    QThread *threadMqtt;
    QTimer *timer;
    void showEvent(QShowEvent*);
    QPoint mousePoint;  //鼠标拖动自定义标题栏时的坐标
    bool mousePressed;  //鼠标是否按下

    void fnInitFormSlots();
    void fnInsidePageAction(QStringList);
    void fnShowMessages(QStringList);
    void fnLoginSucceeded();
    void fnOpenPage(QString);
    void fnOpenDeviceDetail(float version);
    void fnOpenAlarmList(QStringList, QStringList);
    void fnShowLoginWidget();

    MonitorWork *PMonitorWork = nullptr;
    Dialog *PGDialog = nullptr;
    Navigation *PGNavigation = nullptr;
    UsrLogin *PGUsrLogin = nullptr;
    UsrBind *PGUsrBind = nullptr;
    UsrRegister *PGUsrRegister = nullptr;
    UsrFindpwd *PGUsrFindpwd = nullptr;
    UsrSettings *PGUsrSettings = nullptr;
    QtMqtt *PQtMqtt;
    UsrInfo *PGUsrInfo = nullptr;

    DevFaultAlarm *PDevFaultAlarm = nullptr;
    DevFaultList *PDevFaultList = nullptr;
    TianqiYubao *PTianqiYubao;
    WeatherSetup *PGWeatherSetup = nullptr;
    QPointer<DevicesList> PDevicesList;

    SearchDevice *PGSearchDevice = nullptr;
    TopStatistics *PTopStatistics;
    FormMap *PFormMap;
    FDLiangStat *PFDLiangStat;
    DeviceNews *PDeviceNews;
    DeviceStatistics *PDeviceStatistics;
    DeviceStatiSetup *PDeviceStatiSetup = nullptr;
    DevCarousel *PDevCarousel;
    BlackList *PBlackList = nullptr;
    int reOpenCount = 0;
    CameraMonitor *PCameraMonitor = nullptr;

    PassWd *PPassWd = nullptr;
    V10Main *PV10Main = nullptr;
    V15Main *PV15Main = nullptr;
    V20Main *PV20Main = nullptr;

private slots:
    void fnChainLoading(int);
    void fnMonitorWorkInfo(QStringList);

    void onWindowGeometry();
    void onOpenNavigation();
    void fnUpdateTime();
    void fnShowFaultAlarm(QMap<QString, QVariant>);
    void fnCheckNewVersion(bool);

signals:

};
#endif // MONITOR_H
